<template>
  <div class="AdminPage">
    <p>管理界面</p>
    <el-container style="height: 100%; border: 1px solid #eee">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
        <el-menu
          active-text-color="#ffd04b"
          @select="handleSelect"
        >
          <el-menu-item index="1">
            <i class="el-icon-user"></i>
            <span slot="title">用户管理</span>
          </el-menu-item>
          <el-menu-item index="2">
            <i class="el-icon-s-order"></i>
            <span slot="title">订单留存</span>
          </el-menu-item>
          <el-menu-item index="3">
            <i class="el-icon-s-promotion"></i>
            <span slot="title">评论管理</span>
          </el-menu-item>
          <el-menu-item index="4">
            <i class="el-icon-setting"></i>
            <span slot="title">景区审核</span>
          </el-menu-item>
          <el-menu-item index="5">
            <i class="el-icon-setting"></i>
            <span slot="title">酒店审核</span>
          </el-menu-item>
          <!-- <el-menu-item index="6">
            <i class="el-icon-edit"></i>
            <span slot="title">套餐编辑</span>
          </el-menu-item> -->
          <el-menu-item index="7">
            <i class="el-icon-edit"></i>
            <span slot="title">数据更新</span>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <el-container>
        <el-header style="text-align: right; font-size: 30px">
          <el-button type="danger" @click="back()">退出登录</el-button>
        </el-header>

        <el-main style="height: 100%">
          <userTable v-if="flags.users"></userTable>
          <hotelTable v-if="flags.hotels"></hotelTable>
          <landmarkTable v-if="flags.landmarks"></landmarkTable>
          <orderTable v-if="flags.orders"></orderTable>
          <commentTable v-if="flags.comments"></commentTable>
          <p v-if="flags.tc">套餐编辑</p>
          <dataInit v-if="flags.datainit"></dataInit>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import userTable from "../../components/tables/userTable.vue";
import orderTable from "../../components/tables/orderTable.vue";
import commentTable from "../../components/tables/commentTable.vue";
import hotelTable from "@/components/tables/hotelTable.vue";
import landmarkTable from "@/components/tables/landmarkTable.vue";
import dataInit from "@/components/forms/dataInit.vue";
export default {
  name: "admin",
  components: {
    userTable,
    orderTable,
    commentTable,
    hotelTable,
    landmarkTable,
    dataInit,
  },
  data() {
    return {
      flags: this.initFlags(),
    };
  },
  methods: {
    //选择逻辑，初始化flag，全部设置为false
    initFlags() {
    const allFlags = {
      users: false,
      orders: false,
      comments: false,
      landmarks: false,
      hotels: false,
      tc:false,
      datainit:false,
    };
    return allFlags;
  },
  //flag激活
  setFlag(key) {
    this.flags = this.initFlags();
    if(key == "1") this.flags.users = true;
    else if(key == "2") this.flags.orders = true;
    else if(key == "3") this.flags.comments = true;
    else if(key == "4") this.flags.landmarks = true;
    else if(key == "5") this.flags.hotels = true;
    else if(key == "6") this.flags.tc = true;
    else if(key == "7") this.flags.datainit = true;
  },
    // 菜单回调
    handleSelect(key) {
      this.setFlag(key);
    },
    //退出管理端
    back() {
      this.$router.push({ name: "login" });
      this.$notify({
        title: "成功",
        message: "退出管理端成功！",
        type: "success",
      });
    },
  },
  mounted() {},
};
</script>

<style scoped>
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
.AdminPage {
  font-family: serif;
}
</style>
